package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		//从请求中获取相应的参数
        String username = request.getParameter("username"); 
        String password = request.getParameter("password"); 
        
        // 思考，在真实的项目中，接收到参数后要做什么动作？
        
        // 真实的业务操作可能会有哪些动作呢？
        
        //在控制台输出相应的参数
        System.out.println("username = " + username ); 
        System.out.println("password = " + password ); 
        
        //给出响应 
        response.setContentType("text/html"); 
        response.getWriter().println("Login Success!"); 
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		doGet(request, response);
	}
}
